<template>
	<view class="user">
		<div v-if="name!=false">
			<div class="topimg">
				<image src="../../static/header.png" class="img"></image>
				<text>{{name}}</text>
				<text class="txt">新手用户</text>
				<text class="txt">等级/0</text>
			</div>
			<view class="out" @click="out">
				<text>退出登录</text>
			</view>
		</div>
		<please v-else></please>
	</view>
</template>
<script>
	import please from './components/please.vue'
	export default {
		components: {
			please
		},
		data() {
			return {
				name: uni.getStorageSync('userName')
			}
		},
		methods: {
			out() {
				uni.clearStorage();
				uni.showToast({
					title: '退出成功',
					//将值设置为 success 或者直接不用写icon这个参数
					icon: 'success',
					//显示持续时间为 2秒
					duration: 2000
				})
				uni.reLaunch({
					url: '/pages/user/user'
				})
			}
		}
	}
</script>

<style lang="scss">
	.user {
		width: 100vw;
		height: 100vh;

		.topimg {
			margin-top: 1vh;
			width: 100vw;
			height: 8vh;
			display: flex;
			align-items: center;

			.img {
				margin-left: 20rpx;
				width: 15%;
				height: 80%;
				border-radius: 50%;
			}

			text {
				margin-left: 20rpx;
			}

			.txt {
				margin-left: 80rpx;
				color: orangered;
			}
		}

		.out {

			// margin-top: 20rpx;
			margin: 20rpx auto;
			width: 85vw;
			height: 7vh;
			background-color: orangered;
			display: flex;
			justify-content: center;
			align-items: center;
			font-size: 35rpx;
			border-radius: 25rpx;
			color: white;
		}

	}
</style>